﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace WebApplication1
{ 
    public class Jiami
    {

        /// <summary>
        /// MD5加密16进制32位小写
        /// </summary>
        /// <param name="myString"></param>
        /// <returns></returns>
        public static string GetMD5(string myString)
        {
            MD5 md5 = MD5.Create();
            byte[] targetData = md5.ComputeHash(System.Text.Encoding.UTF8.GetBytes(myString));
            string byte2String = "";
            for (int i = 0; i < targetData.Length; i++)
            {
                byte2String = byte2String + targetData[i].ToString("x2");
            }
            return byte2String;
        }

        /// <summary>
        /// MD5加密16位小写
        /// </summary>
        /// <param name="text"></param>
        /// <returns></returns>
        public static string GetMD5By16bit(string text)
        {
            MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
            string t2 = BitConverter.ToString(md5.ComputeHash(UTF8Encoding.UTF8.GetBytes(text)), 4, 8);
            t2 = t2.Replace("-", "");
            t2 = t2.ToLower();
            return t2;
        }



    }
}
